package com.youlai.system.config;


import com.youlai.system.common.result.Result;
import com.youlai.system.common.result.ResultCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


@ControllerAdvice
@Slf4j
public class ExceptionHandlerAdvice {


    @ResponseBody
    @ExceptionHandler
    public Result processException(Exception e){
        log.error("{}",e);
        Result result = new Result();
        result.setCode(ResultCode.USER_ERROR.getCode());
        result.setMsg(ResultCode.USER_ERROR.getMsg());
        return result;
    }


    //@ResponseBody
    //@ExceptionHandler
    //public ApiResponse processException(Exception e) {
    //    log.error("exception msg is:{}", e);
    //    ApiResponse apiResponse = ApiResponse.responseError(e);
    //    return apiResponse;
    //}
}

